package actions;

import game.constants.ReferenceAction;
import interfaces.ActionInterface;
import interfaces.impl.Action;
import objects.WorldObject;
import universe.Universe;

public class ActionPickUpObject extends Action{
	
	WorldObject objetToPickUp=null;

	@Override
	public ActionInterface cloneAction() {
		ActionPickUpObject action = new ActionPickUpObject();
		action.modifyAction(this);
		return action;
	}

	@Override
	public boolean processActionChild(Universe universe) {
		if(objetToPickUp==null){
			return false;
		}
		WorldObject obj = universe.getObject(objetToPickUp.getID());
		if(obj==null){
			return false;
		}
		System.out.println("Recogo el objeto");
		obj.setActive(false);
		obj.setOwner(target.getOwner());
		target.addObject(obj);
		
		return true;
	}

	@Override
	public void initializeName() {
		name="Action Pick Up Object";
		
	}

	@Override
	public void initializeId() {
		id=ReferenceAction.ACTION_PICK_UP_OBJECT;
		
	}

	@Override
	public void modifyChild(ActionInterface action) {
		if (action instanceof ActionPickUpObject){
			objetToPickUp = ((ActionPickUpObject) action).objetToPickUp;
		}
		
	}

	public WorldObject getObjetToPickUp() {
		return objetToPickUp;
	}

	public void setObjetToPickUp(WorldObject objetToPickUp) {
		this.objetToPickUp = objetToPickUp;
	}
	
	

}
